﻿Public Class DAcongelador

    Dim bd As New BTTbdDataContext

    Public Function BuscarCongeladores()

        Dim query = From cong In bd.congeladors _
                    Where cong.estado = True _
                     Select cong
        Return query

    End Function

    Public Function BuscarPisos(ByVal pCodCongelador As Integer)

        Dim query = From piso In bd.pisos _
                    Where piso.id_congelador = pCodCongelador _
                    And piso.estado = True _
                    Select piso
        Return query

    End Function

    Public Function BuscarColumnas(ByVal pCodCongelador As Integer, ByVal pCodPiso As Integer)

        Dim query = From col In bd.columnas _
                    Where col.id_congelador = pCodCongelador _
                    And col.id_piso = pCodPiso _
                    And col.estado = True _
                    Select col

        Return query

    End Function

    Public Function BuscarCajas(ByVal pCodCongelador As Integer, ByVal pCodPiso As Integer, ByVal pCodCol As Integer)

        Dim query = From caja In bd.crioboxes _
                    Where caja.id_congelador = pCodCongelador _
                    And caja.id_piso = pCodPiso _
                    And caja.id_columna = pCodCol _
                    And caja.estado = True _
                    Select caja

        Return query

    End Function

    Public Function BuscarPosiciones(ByVal pCaja As Integer, ByRef nFil As Integer, ByRef nCol As Integer)

        Dim caja As criobox = bd.crioboxes.Single(Function(c As criobox) c.id_box = pCaja)
        nFil = caja.Nro_filas
        nCol = caja.Nro_columnas
        Dim query = From pos In bd.posicions _
                    Where pos.id_box = pCaja _
                    Select pos

        Return query

    End Function

End Class
